<!DOCTYPE html>
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <script src="./vendor/avalon/avalon.js" ></script>
        <script >
            var model1 = avalon.define({
                $id: "test1",
                toggle: false,
                array:[1,2,3,4]
            })

            var model2 = avalon.define({
                $id: "test2",
                num:5
            })

            setTimeout(function() {
                model1.toggle = true
            }, 3000)


            var model3 = avalon.define({
                $id: "test3",
                currentIndex: 0,
                toggle: function(index) {
                    model3.currentIndex = index
                }
            })
        </script>
        <style>
            table{
                width:300px;
                border-collapse: collapse;
                border:1px solid red;
            }
            td {
                padding:5px;
                border:1px solid red;
            }
            .menu{
                display:inline-block;
                *display:inline;
                *zoom:1;
                width:140px;
                padding:5px 20px;
                text-align: center;
                margin-left:1em;
                border: 1px solid greenyellow;
            }
            .btn{
                padding:5px 20px;
                margin-left:1em;
                display: inline-block;
            }
        </style>
    </head>
    <body>

        <div ms-controller="test3">
            <button ms-click="toggle(0)">触发器1</button> 
            <button ms-click="toggle(1)">触发器2</button>
            <button ms-click="toggle(2)" >触发器3</button>
            <div class="ms-tabs" ms-visible="currentIndex === 0">切换卡1<br/>其他内容</div>
            <div class="ms-tabs" ms-visible="currentIndex === 1">切换卡2<br/>及司徒正美</div>
            <div class="ms-tabs" ms-visible="currentIndex === 2">切换卡3<br/>最后一个了</div>
        </div>


        <div ms-controller="test2" >
            <div ms-visible="10 - num > 0">{{num}}</div>
            <!-- data-duplex-event="change"这句加上，回车触发；不加上，每敲一个字符触发 -->
            <input data-duplex-event="change" ms-duplex="num">
        </div>

        <div ms-controller="test1" >
            <table ms-visible="toggle" border="1" >
                <tr><td>1111</td><td>1111</td></tr>
                <tr><td>1111</td><td>1111</td></tr>
            </table>
            <br/>

            <table border="1" >
                <tr><td ms-visible="toggle">test</td><td>2222</td></tr>
                <tr><td>2222</td><td>2222</td></tr>
            </table>

            <table border="1" >
                <tr ms-repeat="array"><td ms-visible="toggle">{{el}}</td><td ms-visible="toggle">{{el+10}}</td></tr>
            </table>

            <div style="display:none" class="menu" ms-visible="toggle">item</div>  
            <div style="display:none" class="menu" ms-visible="toggle">item</div>

            <button style="display:none" class="btn" type="button" ms-visible="toggle">btn</button> 
            <button style="display:none" class="btn" type="button" ms-visible="toggle">btn</button> 
        </div>
    </body>
</html>